home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GX Libraries / PaperTypeLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-16  |  8.6 KB  |  345 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        PaperTypeLibrary.c
  4.  
  5.     Contains:    Handy papertype sample routines.
  6.  
  7.     Version:    Quickdraw GX 1.1
  8.  
  9.     Written by:    Dave Hersey
  10.  
  11.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  12.  
  13.     File Ownership:
  14.  
  15.         DRI:                 Dave Hersey
  16.  
  17.         Other Contact:        Ron Voss
  18.  
  19.         Technology:         QuickDraw GX
  20.  
  21.     Change History (most recent first):
  22.  
  23.          <1>      6/6/95    DH        First checked in.
  24. */
  25.  
  26. #include "PaperTypeLibrary.h"
  27.  
  28.  
  29. /****************************************************************************************
  30.  
  31.                                         GetPaperTypeBaseType
  32.  
  33.     function :
  34.                 GetPaperTypeBaseType returns the specified paper type's base paper type value.
  35.  
  36.     parameters :
  37.                 thePaperType            (in)    reference to target paper type
  38.                 theBasePaperType        (out)    paper type's base value
  39.                 
  40.     returns :
  41.                 error code
  42.  
  43. ****************************************************************************************/
  44. long GetPaperTypeBaseType(
  45.     gxPaperType    thePaperType)
  46. {
  47.     gxBaseInfo info;
  48.     
  49.     GetCollectionItem(GXGetPaperTypeCollection(thePaperType), gxBaseTag, gxPrintingTagID, nil, &info);
  50.     return info.baseType;
  51. }
  52. /* GetPaperTypeBaseType */
  53.  
  54.  
  55. //<FF>
  56. /****************************************************************************************
  57.  
  58.                                         SetPaperTypeBaseType
  59.  
  60.     function :
  61.                 SetPaperTypeBaseType saves the specified base paper type in the target paper type.
  62.  
  63.     parameters :
  64.                 thePaperType        (in)    reference to target paper type
  65.                 theBasePaperType    (in)    new base paper type value
  66.                 
  67.     returns :
  68.                 error code
  69.  
  70. ****************************************************************************************/
  71. void SetPaperTypeBaseType(
  72.     gxPaperType    thePaperType,
  73.     long        theBasePaperType)
  74. {
  75.     gxBaseInfo info;
  76.     
  77.     info.baseType = theBasePaperType;
  78.     AddCollectionItem(GXGetPaperTypeCollection(thePaperType), gxBaseTag, gxPrintingTagID, sizeof(gxBaseInfo), &info);
  79. }
  80. /* SetPaperTypeBaseType */
  81.  
  82.  
  83. //<FF>
  84. /****************************************************************************************
  85.  
  86.                                     GetPaperTypeCreator
  87.  
  88.     function :
  89.                 GetPaperTypeCreator returns the specified paper type's creator.
  90.  
  91.     parameters :
  92.                 thePaperType    (in)    reference to target paper type
  93.                 theCreator        (out)    paper type's creator value
  94.                 
  95.     returns :
  96.                 error code
  97.  
  98. ****************************************************************************************/
  99. OSType GetPaperTypeCreator(
  100.     gxPaperType    thePaperType)
  101. {
  102.     gxCreatorInfo info;
  103.     
  104.     GetCollectionItem(GXGetPaperTypeCollection(thePaperType), gxCreatorTag, gxPrintingTagID, nil, &info);
  105.     return info.creator;
  106. }
  107. /* GetPaperTypeCreator */
  108.  
  109.  
  110. //<FF>
  111. /****************************************************************************************
  112.  
  113.                                     SetPaperTypeCreator
  114.  
  115.     function :
  116.                 SetPaperTypeCreator saves the specified creator in the target paper type.
  117.  
  118.     parameters :
  119.                 thePaperType    (in)    reference to target paper type
  120.                 theCreator        (in)    new paper type creator value
  121.                 
  122.     returns :
  123.                 error code
  124.  
  125. ****************************************************************************************/
  126. void SetPaperTypeCreator(
  127.     gxPaperType    thePaperType,
  128.     OSType        theCreator)
  129. {
  130.     gxCreatorInfo info;
  131.     
  132.     info.creator = theCreator;
  133.     AddCollectionItem(GXGetPaperTypeCollection(thePaperType), gxCreatorTag, gxPrintingTagID, sizeof(gxCreatorInfo), &info);
  134. }
  135. /* SetPaperTypeCreator */
  136.  
  137.  
  138. //<FF>
  139. /****************************************************************************************
  140.  
  141.                                     GetPaperTypeUnits
  142.  
  143.     function :
  144.                 GetPaperTypeUnits returns the specified paper type's units.
  145.  
  146.     parameters :
  147.                 thePaperType    (in)    reference to target paper type
  148.                 theUnits        (out)    paper type's units
  149.                 
  150.     returns :
  151.                 error code
  152.  
  153. ****************************************************************************************/
  154. unsigned char GetPaperTypeUnits(
  155.     gxPaperType        thePaperType)
  156. {
  157.     gxUnitsInfo info;
  158.     
  159.     GetCollectionItem(GXGetPaperTypeCollection(thePaperType), gxUnitsTag, gxPrintingTagID, nil, &info);
  160.     return info.units;
  161. }
  162. /* GetPaperTypeUnits */
  163.  
  164.  
  165. //<FF>
  166. /****************************************************************************************
  167.  
  168.                                     SetPaperTypeUnits
  169.  
  170.     function :
  171.                 SetPaperTypeUnits saves the specified units in the target paper type.
  172.  
  173.                 
  174.     parameters :
  175.                 thePaperType    (in)    reference to target paper type
  176.                 theUnits        (in)    new paper type's units setting
  177.                 
  178.     returns :
  179.                 error code
  180.  
  181. ****************************************************************************************/
  182. void SetPaperTypeUnits(
  183.     gxPaperType        thePaperType,
  184.     unsigned char    theUnits)
  185. {
  186.     gxUnitsInfo info;
  187.     
  188.     info.units = theUnits;
  189.     AddCollectionItem(GXGetPaperTypeCollection(thePaperType), gxUnitsTag, gxPrintingTagID, sizeof(gxUnitsInfo), &info);
  190. }
  191. /* SetPaperTypeUnits */
  192.  
  193.  
  194. //<FF>
  195. /****************************************************************************************
  196.  
  197.                                         GetPaperTypeFlags
  198.  
  199.     function :
  200.                 GetPaperTypeFlags returns the specified paper type's flags.
  201.  
  202.     parameters :
  203.                 thePaperType    (in)    reference to target paper type
  204.                 theFlags        (out)    paper type's flags
  205.                 
  206.     returns :
  207.                 error code
  208.  
  209. ****************************************************************************************/
  210. unsigned long GetPaperTypeFlags(
  211.     gxPaperType            thePaperType)
  212. {
  213.     gxFlagsInfo info;
  214.     
  215.     GetCollectionItem(GXGetPaperTypeCollection(thePaperType), gxFlagsTag, gxPrintingTagID, nil, &info);
  216.     return info.flags & 0x00FFFFFF;
  217. }
  218. /* GetPaperTypeFlags */
  219.  
  220.  
  221. //<FF>
  222. /****************************************************************************************
  223.  
  224.                                     SetPaperTypeFlags
  225.  
  226.     function :
  227.                 SetPaperTypeFlags saves the specified flags in the target paper type.
  228.  
  229.     parameters :
  230.                 thePaperType    (in)    reference to target paper type
  231.                 theFlags        (in)    new paper type's flags setting
  232.                 
  233.     returns :
  234.                 error code
  235.  
  236. ****************************************************************************************/
  237. void SetPaperTypeFlags(
  238.     gxPaperType        thePaperType,
  239.     unsigned long    theFlags)
  240. {
  241.     gxFlagsInfo info;
  242.     
  243.     info.flags = theFlags & 0x00FFFFFF;
  244.     AddCollectionItem(GXGetPaperTypeCollection(thePaperType), gxFlagsTag, gxPrintingTagID, sizeof(gxFlagsInfo), &info);
  245. }
  246. /* SetPaperTypeFlags */
  247.  
  248.  
  249. //<FF>
  250. /****************************************************************************************
  251.  
  252.                                     GetPaperTypeComment
  253.  
  254.     function :
  255.                 GetPaperTypeComment returns the specified paper type's comment.
  256.  
  257.     parameters :
  258.                 thePaperType    (in)    reference to target paper type
  259.                 theComment        (out)    the comment returned (Pascal string)
  260.                 
  261.     returns :
  262.                 error code
  263.  
  264. ****************************************************************************************/
  265. void GetPaperTypeComment(
  266.     gxPaperType    thePaperType,
  267.     Str255        theComment)
  268. {
  269.     long itemSize = sizeof(Str255);
  270.     OSErr anErr = GetCollectionItem(GXGetPaperTypeCollection(thePaperType), gxCommentTag, gxPrintingTagID,
  271.                                               &itemSize, theComment);
  272.     if (anErr)
  273.         theComment[0] = '\0';
  274. }
  275. /* GetPaperTypeComment */
  276.  
  277.  
  278. //<FF>
  279. /****************************************************************************************
  280.  
  281.                                         SetPaperTypeComment
  282.  
  283.     function :
  284.                 SetPaperTypeComment saves the specified comment in the target paper type.
  285.  
  286.     parameters :
  287.                 thePaperType    (in)    reference to target paper type
  288.                 theComment        (in)    the comment to save (Pascal string)
  289.                 
  290.     returns :
  291.                 error code
  292.  
  293. ****************************************************************************************/
  294. OSErr SetPaperTypeComment (
  295.     gxPaperType    thePaperType,
  296.     Str255        theComment)
  297. {
  298.     return AddCollectionItem(GXGetPaperTypeCollection(thePaperType), gxCommentTag, gxPrintingTagID,
  299.                                      theComment[0] + 1, theComment);
  300. }
  301. /* SetPaperTypeComment */
  302.  
  303.  
  304. //<FF>
  305. /****************************************************************************************
  306.  
  307.                                     LockFormatPaperType
  308.  
  309.     function :
  310.                 LockFormatPaperType sets the lock state of the paper type associated with the
  311.                 target format.  To lock the format's paper type, pass true for lockPaperType;
  312.                 otherwise pass false.  A special collection item is attached to the format's
  313.                 collection which contains a single Boolean indicating the current lock state
  314.                 (true if locked; false if not).
  315.  
  316.     parameters :
  317.                 theJob                (in)    reference to the target job
  318.                 theFormat            (in)    reference to the target format
  319.                 lockPaperType        (in)    true => lock the paper type; false => unlock it
  320.                 
  321.     returns :
  322.                 nothing
  323.  
  324. ****************************************************************************************/
  325. void LockFormatPaperType(
  326.     gxFormat        theFormat,
  327.     Boolean        lockPaperType)
  328. {
  329.     OSErr            anErr;
  330.     Collection    formatCollection;
  331.     
  332.     formatCollection = GXGetFormatCollection(theFormat);
  333.  
  334.     anErr = AddCollectionItem(    formatCollection, 
  335.                                         gxPaperTypeLockTag, 
  336.                                         gxPrintingTagID,
  337.                                         sizeof(Boolean), 
  338.                                         &lockPaperType);
  339.  
  340.     if (anErr != noErr)
  341.         GXSetJobError(GXGetFormatJob(theFormat), anErr);
  342. }
  343. /* LockFormatPaperType */
  344.  
  345.